<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        // 时间戳   1970-1-1 带现在的毫秒数

        // 如何获取当前时间戳
        let date = new Date(); //获取日期对象
        // let t = date.getTime()//获取时间戳
        // console.log(t);
        let d2 = date.getDate()

        // 如何将时间戳转为日期
        let tt = 626957541000;
        let date3 = new Date(tt);
        console.log(date3.getFullYear());
        console.log(date3.getMonth());
        console.log(date3.getDate());

        


        // 如何获取指定日期的时间戳
        // let date2 = new Date('2005-10-09 00:00:00');
        let date2 = new Date('2026-01-01 00:00:00');
        // console.log(date3.getDate());
        let d1 = date2.getDate()
        // let t2 = date2.getTime();
        // console.log(t-t2);
        console.log(d1 -d2);
        

    </script>
</body>

</html>